// 选项卡切换
$('.tab').on('click', function () {
	$('.tab').removeClass('active');
	$('.tab-content').removeClass('active');

	$(this).addClass('active');
	const tabId = $(this).data('tab');
	console.log(tabId);
	$(`#${tabId}`).addClass('active');
});

// 获取验证码按钮
$('.code-btn').on('click', function () {
	const $btn = $(this);
	$btn.prop('disabled', true).text('60秒后重发');

	let seconds = 60;
	const timer = setInterval(() => {
		seconds--;
		$btn.text(`${seconds}秒后重发`);

		if (seconds <= 0) {
			clearInterval(timer);
			$btn.prop('disabled', false).text('获取验证码');
		}
	}, 1000);
});
const prov = $('#prov');
const city = $('#city');
const country = $('#country');
let current = {
	prov: '',
	city: '',
	country: ''
}
$.ajax({
	url: 'http://tmtx.test.dgyunju.cn/api/area',
	type: 'get',
	data: { lang: 'zh-cn' },
	dataType: 'json',
	success: function (res) {
		console.log(1);
		const list = res.data
		list.forEach((i, v) => {
			let provOpt = document.createElement('option');
			provOpt.innerText = i.name;
			provOpt.value = i.name
			prov.append(provOpt);
		})
		prov.on("change", function () {
			$('.select-all #city option').remove()
			let textA = prov.val()
			list.forEach(i => {
				if (i.name === textA) {
					i.children.forEach(i2 => {
						let provOpt = document.createElement('option');
						provOpt.innerText = i2.name;
						provOpt.value = i2.name
						city.append(provOpt)
					})
				}
			})
		});
	},
})